package org.example.mybatis.mapper;

import org.apache.ibatis.annotations.*;
import org.example.mybatis.model.UserInfo;
import org.springframework.context.annotation.Primary;

import java.security.Key;
import java.util.List;

@Mapper
public interface UserInfoMapper {
    @Select("select * from userinfo where id=#{id}")
    public List<UserInfo> selectAll(Integer id);
    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into userinfo (username, `password`, age, gender, phone) " +
            "values (#{username},#{password},#{age},#{gender},#{phone})")
    Integer insert(UserInfo userInfo);
    @Delete("delete from userinfo where id=#{id}")
    Integer delete(Integer id);
    @Update("update userinfo set password=#{password} where id=#{id} ")
    Integer update(UserInfo userInfo);
    @Select("select * from userinfo")
    List<UserInfo> select2();
    @Select("select id, username, `password`, age, gender, phone, delete_flag as deleteFlag, " +
            "create_time as createTime, update_time as updateTime from userinfo")
    List<UserInfo> select3();
    @Results(id = "resultMap",value = {
            @Result(column = "delete_flag",property = "deleteFlag"),
            @Result(column = "create_time",property = "createTime"),
            @Result(column = "update_time",property = "updateTime")
    })
    @Select("select * from userinfo")
    List<UserInfo> select4();
    @ResultMap(value = "resultMap")
    @Select("select * from userinfo")
    List<UserInfo> select5();

}
